<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="./js/moment-with-locales.js"></script>
    <script>
      // isBefore()
      console.log(
        moment("2010-10-20").isBefore(),
        moment("2020-10-20").isBefore("2020-10-19"),
        moment("2020-10-20").isBefore("2021-10-19", "year"),
        moment("2020-10-20").isBefore("2008-12-11", "month") // 判断年和月
      );

      // isSame()
      console.log(
        moment("2010-10-20").isSame(),
        moment("2010-10-20").isSame("2020-10-20"),
        moment("2010-10-20").isSame("2020-10-20", "year"),
        moment("2010-10-20").isSame("2020-10-20", "month") // 判断年和月
      );

      // isAfter()
      console.log(moment("2010-10-20").isAfter());

      // isSameOrBefore(): <=
      console.log(moment("2010-10-20").isSameOrBefore());

      // isSameOrAfter()
      console.log(moment("2020-10-20").isSameOrAfter());

      console.log(moment("2010-10-20").isBetween("2010-10-19", "2010-10-25"));
      console.log(moment("2010-10-20").isBetween("2010-10-19", undefined)); // undefined: 表示的就是当前的时间

      // 2.13.0 版本引入了包容性
      console.log(
        moment("2016-10-30").isBetween(
          "2016-10-30",
          "2016-12-30",
          undefined,
          "()"
        )
      );
      console.log(
        moment("2016-10-30").isBetween(
          "2016-10-30",
          "2016-12-30",
          undefined,
          "[)"
        )
      );

      // isLeapYear(): 是否为闰年
      console.log(moment().isLeapYear(), moment("2019").isLeapYear());

      // isMoment(): 是否 Moment
      console.log(
        moment.isMoment(),
        moment.isMoment(new Date()),
        moment.isMoment(moment()),
        moment() instanceof moment
      );

      // moment.isDate(obj): 是否日期
      console.log(moment.isDate());
      console.log(moment.isDate(new Date()));
      console.log(moment.isDate(moment()));
    </script>
  </body>
</html>
